import os

folder_path = "D:/PythonProjects/revised_hot_work_classes6_task2/labels/train"  # 替换为你的文件夹路径

count0, count1, count2, count3, count4, count5 = 0, 0, 0, 0, 0, 0

for filename in os.listdir(folder_path):
    if filename.endswith(".txt"):
        filepath = os.path.join(folder_path, filename)
        with open(filepath, "r") as file:
            for line in file:
                if line.startswith("0"):
                    count0 += 1
                if line.startswith("1"):
                    count1 += 1
                if line.startswith("2"):
                    count2 += 1
                if line.startswith("3"):
                    count3 += 1
                if line.startswith("4"):
                    count4 += 1
                if line.startswith("5"):
                    count5 += 1

print("Number of lines starting with 0 in txt files: ", count0)
print("Number of lines starting with 1 in txt files: ", count1)
print("Number of lines starting with 2 in txt files: ", count2)
print("Number of lines starting with 3 in txt files: ", count3)
print("Number of lines starting with 4 in txt files: ", count4)
print("Number of lines starting with 5 in txt files: ", count5)